﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;

namespace Escape
{
    class VanishBlock: Block
    {

        SoundEffect sound;
        bool isRemoved = false;

        public VanishBlock(Vector3 position)
        {
            this.position = position;

            collisionDistanceX = 0.2f;
            collisionDistanceZ = 0.2f;

            loadTexture("Textures\\vanishBlock");
            sound = Basic.content.Load<SoundEffect>("Sounds\\blockDestroy");
        }

        public override void use()
        {
            if (ItemBar.currentItem is FistItem && !isRemoved && Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                Nullable<float> result = GameScreen.pickRay.Intersects(box);
                if (result.HasValue && result.Value < 1.0f)
                {
                    sound.Play();
                    isRemoved = true;
                    remove();
                }
            }
            base.use();
        }
    }
}
